Skip to content

Update DNS resolve#3

Merged
GediminasKr merged 4 commits intomasterfrom
Improve_git_dns_actions
Oct 6, 2025
Merged

Update DNS resolve#3
GediminasKr merged 4 commits intomasterfrom
Improve_git_dns_actions

Conversation

@GediminasKr
Copy link
Contributor

📝 Description

Improved DNS resolution logic in api-entrypoint.sh for Kubernetes pod operator to run dbt workloads. The previous implementation had an infinite loop without proper timeout or retry limits, causing pods to hang indefinitely when Git repository servers were unreachable. This change implements a robust retry mechanism with configurable parameters and proper error handling.

🎯 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📚 Documentation update
  • 🧪 Test addition or update
  • 🔧 Refactoring (no functional changes)
  • 🚀 Performance improvement
  • 🔒 Security improvement

🔗 Related Issues

  • Fixes DNS resolution infinite loop issue in Kubernetes environments
  • Addresses lack of timeout handling for Git repository connectivity
  • Resolves missing error reporting when repository servers are unreachable

🧪 Testing

  • Unit tests pass
  • Integration tests pass
  • Manual testing completed
  • Documentation updated

Testing Scenarios:

  1. Normal operation: Verified DNS resolution works when Git URL is accessible
  2. Network failure: Tested behavior when Git repository is unreachable (exits after 15 attempts)
  3. Configurable parameters: Verified environment variables override default values
  4. Error logging: Confirmed proper error messages are logged to error.log
  5. Kubernetes compatibility: Tested exit codes and logging format for container orchestration

📋 Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

📸 Screenshots

Before (Infinite Loop):

#Checking DNS Resolve.
if test "${GIT_URL}"; then
until curl --output /dev/null --silent --head --fail ${GIT_URL}; do
    printf "Waiting DNS ${GIT_URL} will be resolved!"
    sleep 5
done

After (Controlled Retry Logic):

#Checking DNS Resolve with retry logic
if test "${GIT_URL}"; then
    echo "Checking DNS resolution for ${GIT_URL}..."
    
    # Configuration for retry logic (configurable via environment variables)
    MAX_RETRIES=${DNS_RETRY_MAX_ATTEMPTS:-15}
    RETRY_INTERVAL=${DNS_RETRY_INTERVAL:-30}
    CONNECT_TIMEOUT=${DNS_CONNECT_TIMEOUT:-10}
    MAX_TIMEOUT=${DNS_MAX_TIMEOUT:-30}
    RETRY_COUNT=0
    
    while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
        if curl --output /dev/null --silent --head --fail --connect-timeout ${CONNECT_TIMEOUT} --max-time ${MAX_TIMEOUT} ${GIT_URL}; then
            echo "DNS resolution successful for ${GIT_URL}"
            break
        else
            RETRY_COUNT=$((RETRY_COUNT + 1))
            echo "DNS resolution attempt ${RETRY_COUNT}/${MAX_RETRIES} failed for ${GIT_URL}"
            
            if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then
                echo "Retrying in ${RETRY_INTERVAL} seconds..."
                sleep $RETRY_INTERVAL
            fi
        fi
    done
    
    # Check if we exhausted all retries
    if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
        log_error "Failed to resolve DNS for ${GIT_URL} after ${MAX_RETRIES} attempts"
        log_error "Repository server is not accessible. Please check network connectivity and DNS configuration."
        exit 1
    fi

🔍 Additional Notes

Key Improvements:

  1. Controlled Retry Logic

    • Maximum 15 attempts (configurable via DNS_RETRY_MAX_ATTEMPTS)
    • 30-second intervals between attempts (configurable via DNS_RETRY_INTERVAL)
    • No more infinite loops
  2. Better Timeout Handling

    • Connect timeout: 10 seconds (configurable via DNS_CONNECT_TIMEOUT)
    • Max timeout: 30 seconds (configurable via DNS_MAX_TIMEOUT)
    • Prevents hanging on network issues
  3. Enhanced Logging

    • Progress tracking with attempt counters
    • Configuration display for debugging
    • Clear success/failure messages
    • Proper error logging using existing log_error function
  4. Configurable Environment Variables

    env:
      - name: DNS_RETRY_MAX_ATTEMPTS
        value: "10"  # Reduce retries if needed
      - name: DNS_RETRY_INTERVAL
        value: "60"  # Increase interval for slower networks
      - name: DNS_CONNECT_TIMEOUT
        value: "15"  # Increase connection timeout
      - name: DNS_MAX_TIMEOUT
        value: "45"  # Increase max timeout
  5. Better Error Handling

    • Explicit exit codes for Kubernetes
    • Clear error messages explaining failures
    • Logs to error file for debugging

Impact:

  • Kubernetes Pods: No more hanging pods due to DNS issues
  • Observability: Clear logging for debugging network problems
  • Configurability: Environment variables allow tuning without code changes
  • Reliability: Predictable behavior with proper timeout handling

Note: Please ensure all CI checks pass before requesting review.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@github-actions
Copy link

github-actions bot commented Oct 6, 2025

🔍 Docker image security scan completed successfully!

No critical vulnerabilities found

Image scanned: docker.io/4fastbi/dbt-workflow-core:pr-3

The scan checked for:

  • Container image vulnerabilities
  • OS package vulnerabilities
  • Application dependencies in the final image

1 similar comment
@github-actions
Copy link

github-actions bot commented Oct 6, 2025

🔍 Docker image security scan completed successfully!

No critical vulnerabilities found

Image scanned: docker.io/4fastbi/dbt-workflow-core:pr-3

The scan checked for:

  • Container image vulnerabilities
  • OS package vulnerabilities
  • Application dependencies in the final image

cursor[bot]

This comment was marked as outdated.

@github-actions
Copy link

github-actions bot commented Oct 6, 2025

🔍 Docker image security scan completed successfully!

No critical vulnerabilities found

Image scanned: docker.io/4fastbi/dbt-workflow-core:pr-3

The scan checked for:

  • Container image vulnerabilities
  • OS package vulnerabilities
  • Application dependencies in the final image

@github-actions
Copy link

github-actions bot commented Oct 6, 2025

🔍 Docker image security scan completed successfully!

No critical vulnerabilities found

Image scanned: docker.io/4fastbi/dbt-workflow-core:pr-3

The scan checked for:

  • Container image vulnerabilities
  • OS package vulnerabilities
  • Application dependencies in the final image

@GediminasKr GediminasKr merged commit f86d121 into master Oct 6, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant